/*
 * @lc app=leetcode.cn id=925 lang=javascript
 *
 * [925] 长按键入
 */

// @lc code=start
/**
 * @param {string} name
 * @param {string} typed
 * @return {boolean}
 */
var isLongPressedName = function (name, typed) {
  name = name.split('');
  typed = typed.split('');
  if (name[0] !== typed[0]) return false;
  let k = 1;
  for (let i = 1; i < typed.length; i++) {
    if (name[k] === typed[i]) {
      k++;
    } else if (typed[i] !== typed[i - 1]) {
      return false;
    }
  }
  return k === name.length;
};
// @lc code=end

